package com.example.zyfypt516wh.fragments;

import android.content.Context;
import android.content.SharedPreferences;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

public class BaseFragments extends Fragment {
    private SharedPreferences sp;
    protected Context context;//保存上下文

    @Override//生命周期第一个方法
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        this.context=context;
        sp=context.getSharedPreferences("login",Context.MODE_PRIVATE);
    }

    protected  String getSessionID()
    {
        return sp.getString("sessionID","");

    }
    protected String getUserName()
    {
        return sp.getString("username","");
    }
}
